# coding=utf-8
from filter import getCharacter
from ToMinst import format
from predict import giveresult
from judge  import getresult
import string
import Tkinter as tk
import os

root = tk.Tk()
root.geometry('500x500')
root.title("判别算式")

l1 = tk.Label(root, bg="yellow", text="图片名称：", width=12)
l1.place(x=80, y=30, anchor='nw')

fn = tk.Entry(root)
fn.place(x=230, y=30, anchor="nw")

l2 = tk.Label(root, bg="yellow", text="设置阈值大小：", width=12)
l2.place(x=80, y=80, anchor='nw')

threshold = tk.Entry(root)
threshold.place(x=230, y=80, anchor="nw")

t = tk.Text(root, width=25, height=5, font=('Verdana', 15), fg="red")
t.place(x=40, y=260)

def del_files(path):
    delList = os.listdir(path)

    for f in delList:
        filePath = os.path.join(path, f)
        os.remove(filePath)


def judge():
    print(fn.get())
    print(threshold.get())

    rst = getCharacter(fn.get(), threshold.get())

    t.delete(0.0, 10.0)
    t.insert(1.0, rst)


start = tk.Button(root, text="开始判断", command=judge)
start.place(x=190, y=160)

root.mainloop()

